/*

Author   : chaos

FileName : link_list.cpp

Date     : 15/08/17 17:45:22

*/
#include <iostream>
using namespace std;

class ListNode
{
    private:
        int data;
        ListNode * next_node;
        static ListNode * now;
        const static ListNode * head;

    public:
        ListNode(int node_data):data(node_data),next_node(NULL){}
        ListNode():next_node(NULL){head = now = this;}
        static void add_node(int new_data);
        static void show_all_node();
};

ListNode * ListNode::now;
const ListNode * ListNode::head;

void ListNode::add_node(int new_data)
{
    now->next_node = new ListNode(new_data);
    now = now->next_node;
}

void ListNode::show_all_node()
{
    int i = 0;
    now = head->next_node;

    while(now != NULL)
    {
        i++;
        cout << "The data of " << i << "node is "
            << now->data << "." << endl;
        now = now->next_node;
    }
}
int main(int argc ,char *argv[])
{
    int data;
    char choice;
    ListNode head;
    do {
        cout << "Plase input data :" << endl;
        cin >> data;

        head.add_node(data);

        cout << endl << "Do you want to input another data !" << endl;
        cin >> choice;
    }while(choice == 'y' || choice == 'Y');

    ListNode::show_all_node();

    return 0;
}
